/**
 * 文件管理
 */

//创建目录
function createDirectory(fileSystem,directory)
{
	fileSystem.root.getFile(directory, {create: true, exclusive: false}, null, fail);
}

//创建文件

function createFile(fileSystem,file){
	fileSystem.root.getFile(file, {create: true, exclusive: false}, success, fail);
}

function success(fileEntry) {
        fileEntry.createWriter(gotFileWriter, fail);
}

function gotFileWriter(writer) {
        writer.onwriteend = function(evt) {
            console.log("contents of file now 'some sample text'");
            writer.truncate(11);  
            writer.onwriteend = function(evt) {
                console.log("contents of file now 'some sample'");
                writer.seek(4);
                writer.write(" different text");
                writer.onwriteend = function(evt){
                    console.log("contents of file now 'some different text'");
                }
            };
        };
        writer.write("some sample text");
}

    function fail(error) {
        console.log(error.code);
    }